<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
      <a-button type="primary" icon="download" @click="handleExportXls('个人贷款发生额信息')">导出</a-button>
      <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">
        <a-button type="primary" icon="import">导入</a-button>
      </a-upload>
      <!-- 高级查询区域 -->
      <j-super-query :fieldList="superFieldList" ref="superQueryModal" @handleSuperQuery="handleSuperQuery"></j-super-query>
      <a-dropdown v-if="selectedRowKeys.length > 0">
        <a-menu slot="overlay">
          <a-menu-item key="1" @click="batchDel"><a-icon type="delete"/>删除</a-menu-item>
        </a-menu>
        <a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>
      </a-dropdown>
    </div>

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
        ref="table"
        size="middle"
        :scroll="{x:true}"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        class="j-table-force-nowrap"
        @change="handleTableChange">

        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" height="25px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;"/>
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="downloadFile(text)">
            下载
          </a-button>
        </template>

        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)">编辑</a>

          <a-divider type="vertical" />
          <a-dropdown>
            <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
            <a-menu slot="overlay">
              <a-menu-item>
                <a @click="handleDetail(record)">详情</a>
              </a-menu-item>
              <a-menu-item>
                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                  <a>删除</a>
                </a-popconfirm>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </span>

      </a-table>
    </div>

    <js-p-amt-per-loan-modal ref="modalForm" @ok="modalFormOk"></js-p-amt-per-loan-modal>
  </a-card>
</template>

<script>

  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import JsPAmtPerLoanModal from './modules/JsPAmtPerLoanModal'

  export default {
    name: 'JsPAmtPerLoanList',
    mixins:[JeecgListMixin, mixinDevice],
    components: {
      JsPAmtPerLoanModal
    },
    data () {
      return {
        description: '个人贷款发生额信息管理页面',
        // 表头
        columns: [
          {
            title: '#',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          {
            title:'贷款发生金额折人民币',
            align:"center",
            dataIndex: 'dkfsjezrmb'
          },
          {
            title:'利率是否固定',
            align:"center",
            dataIndex: 'llsfgd'
          },
          {
            title:'利率水平',
            align:"center",
            dataIndex: 'llsp'
          },
          {
            title:'贷款定价基准类型',
            align:"center",
            dataIndex: 'dkdjjzlx'
          },
          {
            title:'基准利率',
            align:"center",
            dataIndex: 'jzll'
          },
          {
            title:'贷款财政扶持方式',
            align:"center",
            dataIndex: 'dkczfcfs'
          },
          {
            title:'贷款利率重新定价日',
            align:"center",
            dataIndex: 'dkdjcxdjr',
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            }
          },
          {
            title:'贷款担保方式',
            align:"center",
            dataIndex: 'dkdbfs'
          },
          {
            title:'是否首次贷款',
            align:"center",
            dataIndex: 'sfscdk'
          },
          {
            title:'贷款状态',
            align:"center",
            dataIndex: 'dkzt'
          },
          {
            title:'资产证券化产品代码',
            align:"center",
            dataIndex: 'zczqhcpdm'
          },
          {
            title:'贷款重组方式',
            align:"center",
            dataIndex: 'dkczfs'
          },
          {
            title:'发放/收回标识',
            align:"center",
            dataIndex: 'ffhsbs'
          },
          {
            title:'流水号',
            align:"center",
            dataIndex: 'jylsh'
          },
          {
            title:'贷款用途',
            align:"center",
            dataIndex: 'dkyt'
          },
          {
            title:'主键',
            align:"center",
            dataIndex: 'guid'
          },
          {
            title:'数据日期',
            align:"center",
            dataIndex: 'dataDt'
          },
          {
            title:'法人编号',
            align:"center",
            dataIndex: 'legalCode'
          },
          {
            title:'数据机构',
            align:"center",
            dataIndex: 'dataOrg'
          },
          {
            title:'管理部门',
            align:"center",
            dataIndex: 'manageDept'
          },
          {
            title:'数据来源',
            align:"center",
            dataIndex: 'datasource'
          },
          {
            title:'分片数',
            align:"center",
            dataIndex: 'dataSharps'
          },
          {
            title:'创建人',
            align:"center",
            dataIndex: 'creater'
          },
          {
            title:'更新人',
            align:"center",
            dataIndex: 'updater'
          },
          {
            title:'跑批日期',
            align:"center",
            dataIndex: 'etlDt'
          },
          {
            title:'科目代码',
            align:"center",
            dataIndex: 'subjectNo'
          },
          {
            title:'科目名称',
            align:"center",
            dataIndex: 'subjectName'
          },
          {
            title:'客户名称',
            align:"center",
            dataIndex: 'khmc'
          },
          {
            title:'客户代码',
            align:"center",
            dataIndex: 'khdm'
          },
          {
            title:'金融机构代码',
            align:"center",
            dataIndex: 'jrjgdm'
          },
          {
            title:'内部机构号',
            align:"center",
            dataIndex: 'nbjgh'
          },
          {
            title:'金融机构地区代码',
            align:"center",
            dataIndex: 'jrjgdqdm_dictText'
          },
          {
            title:'借款人证件类型',
            align:"center",
            dataIndex: 'jkrzjlx'
          },
          {
            title:'借款人证件代码',
            align:"center",
            dataIndex: 'jkrzjdm'
          },
          {
            title:'借款人地区代码',
            align:"center",
            dataIndex: 'jkrdqdm'
          },
          {
            title:'贷款借据编码',
            align:"center",
            dataIndex: 'dkjjbm'
          },
          {
            title:'贷款合同编码',
            align:"center",
            dataIndex: 'dkhtbm'
          },
          {
            title:'贷款产品类别',
            align:"center",
            dataIndex: 'dkcplb'
          },
          {
            title:'贷款发放日期',
            align:"center",
            dataIndex: 'dkffrq',
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            }
          },
          {
            title:'贷款到期日期',
            align:"center",
            dataIndex: 'dkdqrq',
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            }
          },
          {
            title:'贷款实际终止日期',
            align:"center",
            dataIndex: 'dksjzzrq',
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            }
          },
          {
            title:'币种',
            align:"center",
            dataIndex: 'bz'
          },
          {
            title:'贷款发生金额',
            align:"center",
            dataIndex: 'dkffsje'
          },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            fixed:"right",
            width:147,
            scopedSlots: { customRender: 'action' }
          }
        ],
        url: {
          list: "/jsPAmtPerLoan/jsPAmtPerLoan/list",
          delete: "/jsPAmtPerLoan/jsPAmtPerLoan/delete",
          deleteBatch: "/jsPAmtPerLoan/jsPAmtPerLoan/deleteBatch",
          exportXlsUrl: "/jsPAmtPerLoan/jsPAmtPerLoan/exportXls",
          importExcelUrl: "jsPAmtPerLoan/jsPAmtPerLoan/importExcel",

        },
        dictOptions:{},
        superFieldList:[],
      }
    },
    created() {
    this.getSuperFieldList();
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      },
    },
    methods: {
      initDictConfig(){
      },
      getSuperFieldList(){
        let fieldList=[];
        fieldList.push({type:'number',value:'dkfsjezrmb',text:'贷款发生金额折人民币'})
        fieldList.push({type:'string',value:'llsfgd',text:'利率是否固定'})
        fieldList.push({type:'number',value:'llsp',text:'利率水平'})
        fieldList.push({type:'string',value:'dkdjjzlx',text:'贷款定价基准类型'})
        fieldList.push({type:'number',value:'jzll',text:'基准利率'})
        fieldList.push({type:'string',value:'dkczfcfs',text:'贷款财政扶持方式'})
        fieldList.push({type:'date',value:'dkdjcxdjr',text:'贷款利率重新定价日'})
        fieldList.push({type:'string',value:'dkdbfs',text:'贷款担保方式'})
        fieldList.push({type:'string',value:'sfscdk',text:'是否首次贷款'})
        fieldList.push({type:'string',value:'dkzt',text:'贷款状态'})
        fieldList.push({type:'string',value:'zczqhcpdm',text:'资产证券化产品代码'})
        fieldList.push({type:'string',value:'dkczfs',text:'贷款重组方式'})
        fieldList.push({type:'string',value:'ffhsbs',text:'发放/收回标识'})
        fieldList.push({type:'string',value:'jylsh',text:'流水号'})
        fieldList.push({type:'string',value:'dkyt',text:'贷款用途'})
        fieldList.push({type:'string',value:'guid',text:'主键'})
        fieldList.push({type:'string',value:'dataDt',text:'数据日期'})
        fieldList.push({type:'string',value:'legalCode',text:'法人编号'})
        fieldList.push({type:'string',value:'dataOrg',text:'数据机构'})
        fieldList.push({type:'string',value:'manageDept',text:'管理部门'})
        fieldList.push({type:'string',value:'datasource',text:'数据来源'})
        fieldList.push({type:'int',value:'dataSharps',text:'分片数'})
        fieldList.push({type:'string',value:'creater',text:'创建人'})
        fieldList.push({type:'string',value:'updater',text:'更新人'})
        fieldList.push({type:'string',value:'etlDt',text:'跑批日期'})
        fieldList.push({type:'string',value:'subjectNo',text:'科目代码'})
        fieldList.push({type:'string',value:'subjectName',text:'科目名称'})
        fieldList.push({type:'string',value:'khmc',text:'客户名称'})
        fieldList.push({type:'string',value:'khdm',text:'客户代码'})
        fieldList.push({type:'string',value:'jrjgdm',text:'金融机构代码'})
        fieldList.push({type:'string',value:'nbjgh',text:'内部机构号'})
        fieldList.push({type:'string',value:'jrjgdqdm',text:'金融机构地区代码'})
        fieldList.push({type:'string',value:'jkrzjlx',text:'借款人证件类型'})
        fieldList.push({type:'string',value:'jkrzjdm',text:'借款人证件代码'})
        fieldList.push({type:'string',value:'jkrdqdm',text:'借款人地区代码'})
        fieldList.push({type:'string',value:'dkjjbm',text:'贷款借据编码'})
        fieldList.push({type:'string',value:'dkhtbm',text:'贷款合同编码'})
        fieldList.push({type:'string',value:'dkcplb',text:'贷款产品类别'})
        fieldList.push({type:'date',value:'dkffrq',text:'贷款发放日期'})
        fieldList.push({type:'date',value:'dkdqrq',text:'贷款到期日期'})
        fieldList.push({type:'date',value:'dksjzzrq',text:'贷款实际终止日期'})
        fieldList.push({type:'string',value:'bz',text:'币种'})
        fieldList.push({type:'number',value:'dkffsje',text:'贷款发生金额'})
        this.superFieldList = fieldList
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>